<?php

class LogAction extends CommonAction{

    function lists1() {
    	$type = 1;
    	$data['type'] = $type;
		if($_REQUEST['username'] != null && $_REQUEST['username'] != ""){
			$admin = M('admin');
			$map['username'] = $_REQUEST['username'];
			$adminlist = $admin->where($map)->find();
			if($adminlist != null){
				$data['admin_id'] = $adminlist['id'];
			}else{
				$data['admin_id']=0;
			}
		}
		if($_REQUEST['fromip'] != null && $_REQUEST['fromip'] !=""){
			$data['fromip'] = $_REQUEST['fromip'];
		}
		if($_REQUEST['logintime'] != null && $_REQUEST['logintime'] != ""){
			$time = strtotime($_REQUEST['logintime']);
			$time2 = $time+(3600*24);
			$data['addtime'] = array(array('GT',$time),array('LT',$time2),'and');
		}
		if($_REQUEST['action_content'] != null && $_REQUEST['action_content'] != ""){
			$data['action_content'] = array('like','%'.$_REQUEST['action_content'].'%');
		}

		$m = M('admin_log');
		$this->_listpage($m,$data);
		$this->display();
    }

	function lists2(){
    	$type = 2;
    	$data['type'] = $type;
		if($_REQUEST['username'] != null && $_REQUEST['username'] != ""){
			$admin = M('admin');
			$map['username'] = $_REQUEST['username'];
			$adminlist = $admin->where($map)->find();
			if($adminlist != null){
				$data['admin_id'] = $adminlist['id'];
			}else{
				$data['admin_id']=0;
			}
		}
		if($_REQUEST['fromip'] != null && $_REQUEST['fromip'] !=""){
			$data['fromip'] = $_REQUEST['fromip'];
		}
		if($_REQUEST['logintime'] != null && $_REQUEST['logintime'] != ""){
			$time = strtotime($_REQUEST['logintime']);
			$time2 = $time+(3600*24);
			$data['addtime'] = array(array('GT',$time),array('LT',$time2),'and');
		}
		if($_REQUEST['action_content'] != null && $_REQUEST['action_content'] != ""){
			$data['action_content'] = array('like','%'.$_REQUEST['action_content'].'%');
		}

		$m = M('admin_log');
		$this->_listpage($m,$data);
		$this->display();
	}






    function deleteall(){
		$id = $this->_isempty($_POST['ids'],'ID不能为空');
		$m = M('admin_log');
		$data['id'] = array('in',$id);
		$isok = $m->where($data)->delete();
		if($isok){
			$this->success("删除成功");
		}

    }




}
?>